let logger = require("pomelo-logger").getLogger(__filename);

module.exports = function (app) {
    return new Handler(app);
};

let Handler = function (app) {
    this.app = app;
};

Handler.prototype.getGameRecords = function (msg, session, callback) {
    let player = session["player"];
    if (!player) {
        logger.error("getGameRecords empty player");
        callback(null, {resultCode: 404, message: "请先登录", gameRecords : []});
        return;
    }

    let gameRecordService = this.app.get("gameRecordService");
    gameRecordService.getGameRecords(msg, player, function (records){
        callback(null, {resultCode: 0, message: "ok", gameRecords: gameRecordService.serializeGameRecords(records)});
    });
};